home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / readers / skim-0.8 / skim-0 / skim-0.8.4 / AuthorParseTest.c < prev    next >
C/C++ Source or Header  |  1996-02-18  |  2KB  |  77 lines

  1. /*
  2.  * NAME
  3.  *   AuthorParseTest.c
  4.  * DESCRIPTION
  5.  *   Test the parser which gets the full name of the Author from the
  6.  *   "From:" header line. Run this test by typing 'make test' in the source
  7.  *   directory of skim.
  8.  * COPYRIGHT
  9.  *   AuthorParseTest
  10.  *   Copyright (C) 1996  Rene W.J. Pijlman
  11.  *
  12.  *   This program is free software; you can redistribute it and/or modify
  13.  *   it under the terms of the GNU General Public License as published by
  14.  *   the Free Software Foundation; either version 2 of the License, or
  15.  *   (at your option) any later version.
  16.  *
  17.  *   This program is distributed in the hope that it will be useful,
  18.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20.  *   GNU General Public License for more details.
  21.  *
  22.  *   You should have received a copy of the GNU General Public License
  23.  *   along with this program; if not, write to the Free Software
  24.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  * VERSION
  26.  *   $Header: /home/rene/sys/CVS_MasterSourceRepository/skim/AuthorParseTest.c,v 1.4 1996/02/18 11:40:17 rene Exp $
  27.  *   Distributed with Skim version 0.8.4.
  28.  */
  29.  
  30. #include <string.h>
  31. #include <stdio.h>
  32.  
  33. #include "VarBuf.h"
  34. #include "SkimUtils.h"
  35.  
  36. int main(void)
  37. {
  38.     int i;
  39.     VarBuf From = VBCreate();
  40.     Boolean TestSucceeded = True;
  41.  
  42.     static char * TestPairs[] = {
  43.     /* From field. */              /* Expected Author */
  44.     "foo@bar.org (Foo Bar)"      , "Foo Bar",
  45.     "Foo Bar <foo@bar.org>"      , "Foo Bar",
  46.     "foo@bar.org"                , "foo@bar.org",
  47.     "\"Foo Bar\" <foo@bar.org>"  , "Foo Bar",
  48.     "foo@bar.org ()"             , "foo@bar.org"
  49.     };
  50.  
  51.     for ( i = 0; i < sizeof TestPairs / sizeof TestPairs[0]; i += 2 )
  52.     {
  53.     VBReset( From );
  54.  
  55.         VBPrintf( From, "%s", TestPairs[i] );
  56.  
  57.         AuthorFromFromField( From );
  58.  
  59.     if( strcmp(VBAsString(From), TestPairs[i+1]) )
  60.     {
  61.         fprintf( stderr,
  62.         "AuthorFromFromField() failed '%s' --> '%s', expected '%s'\n",
  63.         TestPairs[i], VBAsString(From), TestPairs[i+1] );
  64.         TestSucceeded = False;
  65.     }
  66.     }
  67.  
  68.     VBDestroy( From );
  69.  
  70.     if ( TestSucceeded )
  71.     {
  72.     SIOPrintf( StandardOutput, "OK\n" );
  73.     }
  74.  
  75.     return TestSucceeded ? EXIT_SUCCESS : EXIT_FAILURE;
  76. }
  77.